feat(db): nullable MonthlyCost on PurchaseHistoryRecord (closes #255)#848
feat(db): nullable MonthlyCost on PurchaseHistoryRecord (closes #255)#848cristim wants to merge 2 commits into
Conversation
|
Warning Review limit reached
More reviews will be available in 22 minutes and 59 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (21)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
Migration 000063 drops NOT NULL on purchase_history.monthly_cost so rows from providers without a monthly recurring breakdown (Azure/GCP all-upfront) can store NULL instead of a misleading 0.0. - PurchaseHistoryRecord.MonthlyCost: float64 -> *float64 - InventoryCommitment.MonthlyCost: float64 -> *float64 - All scan loops use sql.NullFloat64; nil DB value -> nil pointer - execution.go: remove derefFloat64; pass pointer straight through - handler_inventory.go: skip nil MonthlyCost in coverage aggregation - handler_history.go: sumRecommendationMonthlyCostPtr returns nil when every rec has nil MonthlyCost (renders as -- not $0.00) - Frontend: monthly_cost typed number|null; inventory cell renders -- - All test fixtures and assertions updated to use *float64 (pf helper)
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary
PurchaseHistoryRecord.MonthlyCosta*float64(nullable) so rows from providers that do not return a monthly recurring cost (e.g. Azure/GCP all-upfront) storeNULLinstead of a misleading0.0.NOT NULLconstraint onpurchase_history.monthly_cost; rollback coerces anyNULLs back to0.0before re-adding the constraint.sql.NullFloat64in all three copies of the scan loop (production, comprehensive-test mock, additional-test mock) soNULLDB values materialise as anilpointer and0.0DB values materialise as&0.0, preserving the semantic distinction.derefFloat64helper inexecution.gothat previously flattened nil to 0; now the pointer is passed through to the history record unchanged.monthly_costtyped asnumber | null; inventory commitment cell renders—when null,$X.XXotherwise.MonthlyCostskip nil entries (no distortion of totals).Test plan
go build ./...cleango test github.com/LeanerCloud/CUDly/internal/config/... github.com/LeanerCloud/CUDly/internal/api/...1906 passpurchase_history.monthly_cost; rollback NULLs-to-0 before re-adding constraintMonthlyCostentries rather than adding zeroCloses #255